<template>
    <view class="sound-settings-page">
        <!-- 顶部导航栏 -->
        <view class="header">
            <uni-nav-bar :border="false" backgroundColor="#ffffff" statusBar>
                <template v-slot:left>
                    <view class="nav-left" @click="goBack">
                        <uni-icons type="back" size="20"></uni-icons>
                    </view>
                </template>
                <template v-slot:default>
                    <view class="nav-center">
                        <text class="nav-title">声音通知</text>
                    </view>
                </template>
            </uni-nav-bar>
        </view>
        <view class="settings-item-separate">
            <text class="item-label">收款提醒</text>
            <switch :checked="soundSettings.payment" @change="toggleSetting('payment')" color="#007AFF"
                style="transform: scale(0.7);" />
        </view>
        <!-- 设置内容区域 -->
        <view class="settings-content">
            <view class="settings-section">
                <view class="settings-content-wrapper">

                    <view class="settings-item">
                        <text class="item-label">保洁工单提醒</text>
                        <switch :checked="soundSettings.cleaning" @change="toggleSetting('cleaning')" color="#007AFF"
                            style="transform: scale(0.7);" />
                    </view>
                    <view class="settings-item">
                        <text class="item-label">报修工单提醒</text>
                        <switch :checked="soundSettings.repair" @change="toggleSetting('repair')" color="#007AFF"
                            style="transform: scale(0.7);" />
                    </view>
                    <view class="settings-item">
                        <text class="item-label">反馈工单提醒</text>
                        <switch :checked="soundSettings.feedback" @change="toggleSetting('feedback')" color="#007AFF"
                            style="transform: scale(0.7);" />
                    </view>
                    <view class="settings-item">
                        <text class="item-label">看房工单提醒</text>
                        <switch :checked="soundSettings.viewing" @change="toggleSetting('viewing')" color="#007AFF"
                            style="transform: scale(0.7);" />
                    </view>
                    <view class="settings-item">
                        <text class="item-label">全民出房租客预定提醒</text>
                        <switch :checked="soundSettings.reservation" @change="toggleSetting('reservation')"
                            color="#007AFF" style="transform: scale(0.7);" />
                    </view>
                    <view class="settings-item">
                        <text class="item-label">租客IM消息提醒</text>
                        <switch :checked="soundSettings.tenantMessage" @change="toggleSetting('tenantMessage')"
                            color="#007AFF" style="transform: scale(0.7);" />
                    </view>
                </view>
                <view class="settings-tip">
                    <text>开启后，当有收款/工单消息时会播放语音提醒</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            soundSettings: {
                payment: false,
                cleaning: false,
                repair: false,
                feedback: false,
                viewing: false,
                reservation: false,
                tenantMessage: false
            }
        }
    },
    methods: {
        goBack() {
            uni.navigateBack();
        },
        toggleSetting(key) {
            this.soundSettings[key] = !this.soundSettings[key];
            // 这里可以添加保存设置的逻辑
            uni.showToast({
                title: this.soundSettings[key] ? '已开启' : '已关闭',
                icon: 'none'
            });
        }
    }
}
</script>

<style lang="scss" scoped>
.sound-settings-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f5f5f5;
}

.header {
    background-color: #ffffff;
}

.nav-left {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60rpx;
    height: 60rpx;
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;

    .nav-title {
        font-size: 30rpx;
        font-weight: normal;
        color: #333;
    }
}

.settings-content {
    flex: 1;
    padding: 20rpx 0;
}

.settings-section {
    margin-bottom: 20rpx;

    .settings-content-wrapper {
        background-color: #ffffff;
    }

    .settings-tip {
        padding: 20rpx 30rpx;
        font-size: 24rpx;
        color: #999;
    }
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30rpx;
    border-bottom: 1rpx solid #f5f5f5;
    height: 48rpx;

    &:last-child {
        border-bottom: none;
    }
}

.settings-item-separate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30rpx;
    height: 48rpx;
    background-color: #ffffff;
    margin-top: 20rpx;
}

.item-label {
    font-size: 28rpx;
    color: #333;
}
</style>